import { request }  from "@/utils/request.js";
// 登录
export const login =  (data) =>  {
	return request({url: 'auth/login', method: 'POST', data})
};
// 配置信息
export const configs =  (data = {}) =>  {
	return request({url: 'configs', data})
};
// 获取用户信息
export const personal =  (data={}) =>  {
	return request({url: 'personal', data})
};
// 更新用户信息
export const updatePersonal =  (data) =>  {
	return request({url: 'personal', method: 'PUT', data})
};
// 车辆分类列表
export const carCategories =  (data={}) =>  {
	return request({url: 'car_categories', data})
};
// 车辆列表
export const cars =  (data) =>  {
	let str = "";
	for(let index in data.configs){
	    str+=`configs[${index}]=`+data.configs[index]+'&'
	}
	str+=`category_id=${data.category_id}&page=${data.page}&day=${data.day}&price_direction=${data.price_direction}&volume_direction=${data.volume_direction}&start_time=${data.startTime}&end_time=${data.endTime}`
	if (data.is_hot) {
		str = str+'&is_hot='+data.is_hot
	}
	return request({url: `cars?${str}`})
};
// 车辆详情
export const carsDetail =  (id, data) =>  {
	return request({url: `cars/${id}`, data})
};
//  订单确认 
export const ordersConfirm =  (data) =>  {
	return request({url: 'orders/confirm', data})
};
// 订单创建
export const orders =  (data) =>  {
	return request({url: 'orders', method: 'POST', data})
};
// 获取支付参数
export const payParameter = (id) =>  {
	return request({url: `orders/${id}/pay_parameter`})
};
// // 获取支付参数
// export const payParameter = (id) =>  {
// 	return request({url: `orders/${id}/pay_success`})
// };
// 订单列表
export const ordersList = (data) =>  {
	return request({url: 'orders', data})
};
// 订单详情
export const orderDetail = (id) =>  {
	return request({url: `orders/${id}`})
};
// 修改承租人
export const lessees = (data) =>  {
	return request({url: `lessees/${data.id}`, method: 'PUT', data})
};
// 承租人列表
export const getLessees =  (data={}) =>  {
	return request({url: 'lessees', data})
};
// 取消订单
export const cancel =  (id) =>  {
	return request({url: `orders/${id}/cancel`, method: 'PUT'})
};
// 确认还车
export const returnCart =  (id) =>  {
	return request({url: `orders/${id}/return`, method: 'PUT'})
};
// 修改承租人
export const updateLessees = (data) =>  {
	return request({url: `lessees/${data.id}`, method: 'PUT', data})
};
// 更新承租人默认地址
export const updateDefault = (id) =>  {
	return request({url: `lessees/${id}/default`, method: 'PUT', data: {"is_default": "1"}})
};
// 添加承租人
export const addLessees = (data) =>  {
	return request({url: 'lessees', method: 'POST', data})
};
// 删除承租人
export const delLessees = (id) =>  {
	return request({url: `lessees/${id}`, method: 'DELETE'})
};